package win.demonlegion.util;

import org.apache.commons.codec.binary.Base64;

import java.nio.charset.StandardCharsets;

public class Base64Util {
    public static String toBase64(byte[] byteBuffer) {
        return new String(Base64.encodeBase64(byteBuffer), StandardCharsets.UTF_8);
    }

    public static String toBase64(String origin) {
        return toBase64(origin.getBytes(StandardCharsets.UTF_8));
    }

    public static String parseBase64(String base64String) {
        return new String(Base64.decodeBase64(base64String), StandardCharsets.UTF_8);
    }

    public static byte[] parseBase64(byte[] byteBuffer) {
        return Base64.decodeBase64(byteBuffer);
    }
}
